import request from '@/util/request';

//修改求职者基本信息
export const changeBasicMessage = async (data) => {
  try {
    const response = await request.post("/seeker/profile/editBasicMessage", data);
    return response;
  } catch (error) {
    console.error('获取基本信息失败:', error);
    throw error;
  }
};

//获取求职者项目经历
export const getProjectExperience = async () => {
  console.log("进入getProjectExperience")
  try {
    const response = await request.get("/seeker/profile/getProjectExperience");
    console.log(response);
    return response;
  } catch (error) {
    console.error('获取项目经历失败:', error);
    throw error;
  }
};

//获取求职者工作经历
export const getWorkExperience = async () => {
  try {
    const response = await request.get("/seeker/profile/getWorkExperience");
    return response;
  } catch (error) {
    console.error('获取工作经历失败:', error);
    throw error;
  }
};

//修改求职者项目经历
export const updateProjectExperience = async (data) => {
  try {
    console.log("进入接口")
    const response = await request.post("/seeker/profile/editProjectExperience", data);
    return response;
  } catch (error) {
    console.error('修改项目经历失败:', error);
    throw error;
  }
};

//修改求职者工作经历
export const updateWorkExperience = async (data) => {
  try {
    const response = await request.post("/seeker/profile/editWorkExperience", data);
    return response;
  } catch (error) {
    console.error('修改工作经历失败:', error);
    throw error;
  }
};
// 提交/修改简历
export const submitCv = async (susername, cv) => {
  try {
    const data = new FormData();
    data.append("susername", susername);
    data.append("cv", cv);
    const response = await request.post("/hqdx/seeker/reviseCV", data);
    return response;
  } catch (error) {
    console.error('提交/修改简历失败:', error);
    throw error;
  }
};

// 退出登录
export const logoutSeeker = async (susername) => {
  try {
    const data = new FormData();
    data.append("susername", susername);
    const response = await request.post("/hqdx/seeker/loginout", data);
    return response;
  } catch (error) {
    console.error('退出登录失败:', error);
    throw error;
  }
};

// 修改密码
export const changePassword = async (data) => {
  try {
    const response = await request.post("/seeker/auth/resetPassword", data);
    return response;
  } catch (error) {
    console.error('修改密码失败:', error);
    throw error;
  }
};

// 修改手机号
export const changePhoneNum = async (data) => {
  try {
    const response = await request.post("/seeker/auth/resetPhone", data);
    return response;
  } catch (error) {
    console.error('修改手机号失败:', error);
    throw error;
  }
};

// 上传头像
export const uploadAvatar = async (data) => {
  try {
    const response = await request.post("/seeker/profile/uploadAvatar", data,{

      headers: {
        'Content-Type': 'multipart/form-data'
      }
    });
    return response;
  } catch (error) {
    console.error('上传头像失败:', error);
    throw error;
  }
};



